﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using WindowsPhoneEssentials.Abstractions;
using WindowsPhoneEssentials.Storage;
using WindowsPhoneEssentials.Testing.Abstractions;

namespace WindowsPhoneEssentials.Tests.Storage
{
    [TestClass]
    public class PersistentStoreTests
    {
        private PersistentStore applicationTransientStore;
        private MemoryIsolatedStorateFileFactory memoryIsolatedStorateFileFactory;
        private IIsolatedStorageFile store;

        [TestInitialize]
        public void Setup()
        {
            memoryIsolatedStorateFileFactory = new MemoryIsolatedStorateFileFactory();
            store = memoryIsolatedStorateFileFactory.GetUserStoreForApplication();
            applicationTransientStore = new PersistentStore(memoryIsolatedStorateFileFactory);
        }

        [TestMethod]
        public void can_save_and_restore_simple_type()
        {
            // arrange
            const string value = "test";

            // act
            applicationTransientStore.Save("key", value);

            // assert
            Assert.AreEqual("test", applicationTransientStore.Load<string>("key"));
        }
    }
}